/* Copyright (c) 2006 Mathias Bank (http://www.mathias-bank.de)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Thanks to Hinnerk Ruemenapf - http://hinnerk.ruemenapf.de/ for bug reporting and fixing.
*/
jQuery.extend({
	/**
	* Returns get parameters.
	*
	* If the desired param does not exist, null will be returned
	*
	* @example value = $.getURLParam("paramName");
	*/
	getURLParam: function (strParamName) {
		var strReturn = "";
		var strHref = window.location.href;
		var bFound = false;
		
		var cmpstring = strParamName + "=";
		var cmplen = cmpstring.length;
		
		if (strHref.indexOf("?") > - 1) {
			var strQueryString = strHref.substr(strHref.indexOf("?") + 1);
			var aQueryString = strQueryString.split("&");
			for (var iParam = 0; iParam < aQueryString.length; iParam++) {
				if (aQueryString[iParam].substr(0, cmplen) == cmpstring) {
					var aParam = aQueryString[iParam].split("=");
					strReturn = unescape(aParam[1]);
					bFound = true;
					break;
				}
			}
		}
		if (bFound == false) return null;
		return strReturn;
	}
});

/************************************
QUICKSEARCH
Written by Ethan Gruber, ewg4x@virginia.edu
Library: jQuery
populates hidden query parameter in results page quick search
************************************/
$(function () {
	$('#qs_button') .click(function () {
		var search_text = $('#qs_text') .attr('value');
		var query = $.getURLParam('q');
		if (query == '*:*') {
			$('#qs_query') .attr('value', 'fulltext:' + search_text);
		} else {
			$('#qs_query') .attr('value', query + ' AND fulltext:' + search_text);
		}
	});
});